package cn.xiaohaoo.process;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 分析有效数据
 */
public class DatasetsAnalysis {
    private static final Logger LOGGER = LoggerFactory.getLogger(DatasetsAnalysis.class);

    public static void main(String[] args) throws IOException {
        Map<String, Object> map = new HashMap<>();
        Files.list(Paths.get("./datasets/dataset3")).forEach(v -> {
            map.put(v.getFileName().toString().split("\\.")[0], 0);
        });


        long sum1 = Files.list(Paths.get("./datasets/dataset1"))
                .map(v -> v.getFileName().toString().split("\\.")[0])
                .filter(s -> map.get(s) != null).count();

        LOGGER.info("dataset1中总共{}", Files.list(Paths.get("./datasets/dataset1")).count());
        LOGGER.info("dataset1中有效图片{}", sum1);

        long sum2 = Files.list(Paths.get("./datasets/dataset2"))
                .filter(Objects::nonNull).count();
        ;
        LOGGER.info("dataset2中总共{}", Files.list(Paths.get("./datasets/dataset2")).count());
        LOGGER.info("dataset2中有效图片{}", sum2);
    }

}
